#!/bin/sh

# Slackware build script for liberation-fonts-ttf

# Written by core (eroc@linuxmail.org)
# I took some ideas from alienBOB's slackbuild:
# http://www.slackware.com/~alien/slackbuilds/liberation-fonts/build/liberation-fonts.SlackBuild

set -e

PRGNAM=liberation-fonts-ttf
PRGNAMALT=liberation-fonts
VERSION=3
VERSIONALT=0.2
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar -xzvf $CWD/$PRGNAM-$VERSION.tar.gz
mv $PRGNAMALT-$VERSIONALT $PRGNAM-$VERSION
cd $PRGNAM-$VERSION
chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# To determinate Xorg's location
XPREF=$(pkg-config --variable=prefix x11) || true
if [ "$XPREF" == "/usr" ]; then
    FONTDIR="$PKG/usr/share/fonts/TTF"
else
    FONTDIR="$PKG/usr/X11R6/lib/X11/fonts/TTF"
fi

mkdir -p $FONTDIR/
cp -a *.ttf $FONTDIR/

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a COPYING License.txt $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
